
/*
* SuppliersDAL
*/
using System;
using System.Collections;
using System.Data;
using System.Data.Common;
using System.Collections.Generic;

using WHC.Pager.Entity;
using Microsoft.Practices.EnterpriseLibrary.Data;
using Carmall.Entity;
using Carmall.IDAL;

namespace Carmall.DAL
{
	/// <summary>
	/// Suppliers 的摘要说明。
	/// </summary>
	public class Suppliers : BaseDAL<SuppliersInfo>, ISuppliers
	{
		#region 对象实例及构造函数

		public static Suppliers Instance
		{
			get
			{
				return new Suppliers();
			}
		}
		public Suppliers() : base("suppliers","SupplierNo")
		{
		}

		#endregion

		/// <summary>
		/// 将DataReader的属性值转化为实体类的属性值，返回实体类
		/// </summary>
		/// <param name="dr">有效的DataReader对象</param>
		/// <returns>实体类对象</returns>
		protected override SuppliersInfo DataReaderToEntity(IDataReader dataReader)
		{
			SuppliersInfo suppliersInfo = new SuppliersInfo();
			SmartDataReader reader = new SmartDataReader(dataReader);
			
			
			suppliersInfo.SupplierNo = reader.GetString("SupplierNo");
			suppliersInfo.UserID = reader.GetInt64("UserID");
			suppliersInfo.ShortName = reader.GetString("ShortName");
			suppliersInfo.CompanyName = reader.GetString("CompanyName");
			suppliersInfo.Mobile = reader.GetString("Mobile");
			suppliersInfo.Tel = reader.GetString("Tel");
			suppliersInfo.Fax = reader.GetString("Fax");
			suppliersInfo.Email = reader.GetString("Email");
			suppliersInfo.Contact = reader.GetString("Contact");
			suppliersInfo.ZipCode = reader.GetString("ZipCode");
			suppliersInfo.Place = reader.GetString("Place");
			suppliersInfo.Address = reader.GetString("Address");
			suppliersInfo.Description = reader.GetString("Description");
			suppliersInfo.Notes = reader.GetString("Notes");
			suppliersInfo.Licence = reader.GetString("Licence");
			suppliersInfo.IdCard = reader.GetString("IdCard");
			suppliersInfo.Authorize = reader.GetString("Authorize");
			suppliersInfo.Cert = reader.GetString("Cert");

			
			return suppliersInfo;
		}

		/// <summary>
		/// 将实体对象的属性值转化为Hashtable对应的键值
		/// </summary>
		/// <param name="obj">有效的实体对象</param>
		/// <returns>包含键值映射的Hashtable</returns>
		protected override Hashtable GetHashByEntity(SuppliersInfo obj)
		{
			SuppliersInfo info = obj as SuppliersInfo;
			Hashtable hash = new Hashtable(); 
			
			
			hash.Add("SupplierNo", TypeHelper.SafeString(info.SupplierNo));
			hash.Add("UserID", TypeHelper.SafeInt(info.UserID));
			hash.Add("ShortName", TypeHelper.SafeString(info.ShortName));
			hash.Add("CompanyName", TypeHelper.SafeString(info.CompanyName));
			hash.Add("Mobile", TypeHelper.SafeString(info.Mobile));
			hash.Add("Tel", TypeHelper.SafeString(info.Tel));
			hash.Add("Fax", TypeHelper.SafeString(info.Fax));
			hash.Add("Email", TypeHelper.SafeString(info.Email));
			hash.Add("Contact", TypeHelper.SafeString(info.Contact));
			hash.Add("ZipCode", TypeHelper.SafeString(info.ZipCode));
			hash.Add("Place", TypeHelper.SafeString(info.Place));
			hash.Add("Address", TypeHelper.SafeString(info.Address));
			hash.Add("Description", TypeHelper.SafeString(info.Description));
			hash.Add("Notes", TypeHelper.SafeString(info.Notes));
			hash.Add("Licence", TypeHelper.SafeString(info.Licence));
			hash.Add("IdCard", TypeHelper.SafeString(info.IdCard));
			hash.Add("Authorize", TypeHelper.SafeString(info.Authorize));
			hash.Add("Cert", TypeHelper.SafeString(info.Cert));

			
			return hash;
		}
	}
}
